#!/bin/bash
adb uninstall com.jimo.app
adb uninstall com.mi.earphone
adb install xiaomi.apk
set -e
cd "$(dirname "$0")"

# 构建 release APK
./gradlew injector:assembleDebug

# 获取 APK 路径
APK_PATH=injector/build/outputs/apk/debug/injector.apk

# assets 目录
DEX_DIR=app/src/main/assets
mkdir -p "$DEX_DIR"

# 一次性解压 dex 和 lib
unzip -o "$APK_PATH" "classes*.dex" "lib/**" -d "$DEX_DIR"

# 重命名 dex
mv "$DEX_DIR/classes.dex" "$DEX_DIR/injector.dex"

echo "✅ Dex 和 lib 已经解压到 $DEX_DIR"

#adb uninstall com.deepseek.chat
#adb install /Users/jimo/AndroidStudioProjects/algui/test.apk